#define _CRT_SECURE_NO_WARNINGS 1

#include<stdio.h>

#include<ctype.h>



int main()
{
	int n = 0;
	scanf("%d", &n);
	getchar();
	while (n--) {
		int count = 0;
		char a[1000];
		fgets(a, sizeof(a), stdin);
		for (int i = 0; a[i] != '\0'; i++) {
			if (isdigit(a[i])) {
				count++;
			}
		}
		printf("%d\n", count);
	}
	return 0;
}